/**** accessible context variables
AuthorElement selectedElement
DocumentFragment selectedFragment
ArgumentsMap argumentsMap
DocumentController controller
AuthorAccess authorAccess
Map<String, String> argumentsValues
globalObject
****/

var OptStore = authorAccess.getOptionsStorage();

var mainElement = selectedElement;
while (mainElement.getName() != "строка")
mainElement = mainElement.getParent();

var elements = mainElement.getContentNodes();
try {
    for (var i = 0; i < elements.size();
    i++) {
        try {
            /*authorAccess.showErrorMessage(elements.get(i).getName() + " : " + elements.get(i).getType());
            
            var colspan = elements.get(i).getAttribute("colspan");
            if (colspan != null) {
            authorAccess.showErrorMessage(colspan.getValue());
            OptStore.setOption("colspan in cell" + i, colspan.getValue());
            } else*/
            //authorAccess.showErrorMessage("without colspan attribute");
            globalObject.setAttrValue(elements.get(i), "colspan", "2");
        }
        catch (err) {
            authorAccess.showErrorMessage(err);
        }
    }
}
catch (err) {
    authorAccess.showErrorMessage("Error: " + err);
}

var table = mainElement.getParent();
var stringXmlTable = controller.serializeFragmentToXML(controller.createDocumentFragment(table, true));
authorAccess.showErrorMessage(stringXmlTable);
/*var xmlTable = <root>{stringXmlTable}</root>;
authorAccess.showErrorMessage(xmlTable);*/

/*

var mycontroller = authorAccess.getDocumentController();
try {
var start = authorAccess.getSelectionStart();
var end = authorAccess.getSelectionEnd();
var fragment = controller.createDocumentFragment(start, end);
authorAccess.showErrorMessage("fragment size " + fragment.getLength());
}
catch (err) {
authorAccess.showErrorMessage("Error on create fragment: " + err.description);
}

mycontroller.insertText(authorAccess.getCaretOffset(), "my text here");*/